package com.ruix.app.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
import com.ruix.app.R;

/**
 * Created by hadexs on 2017/4/30.
 */

public class ReleaseLearningFeelDialog extends Dialog implements View.OnClickListener{



    private AcitonListener listener;

    public ReleaseLearningFeelDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_release_learning_feel);
        setCanceledOnTouchOutside(false);
        initEvent();

        Window dialogWindow = getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.gravity = Gravity.CENTER;
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;//宽高可设置具体大小
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        dialogWindow.setAttributes(lp);

        //

    }

    private void initEvent(){
        ImageView message = (ImageView) findViewById(R.id.iv_fly_gift);
        Glide.with(getContext()).load(R.drawable.release_gif).into(new GlideDrawableImageViewTarget(message,Integer.MAX_VALUE));
        findViewById(R.id.btn_goto_practice).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_goto_practice:
                dismiss();
                if (listener != null){
                    listener.positiveAction();
                }
                break;
        }
    }

    public void setListener(AcitonListener listener) {
        this.listener = listener;
    }



    public interface AcitonListener{
        void positiveAction();
        void negertivieAction();
        void dismisssAction();
    }
}
